package inutan.game.action;

import inutan.common.constant.DataConstant;
import inutan.game.business.GameFlowContext;
import inutan.game.service.TaskService;
import luban.common.Command;
import org.ricks.ioc.anno.Action;
import org.ricks.ioc.anno.ActionMethod;
import org.ricks.ioc.anno.Autowired;
import org.ricks.net.DataCodecKit;
import org.ricks.net.DefaultPacket;

@Action(modularId = 1)
public class TaskController {

    @Autowired
    private TaskService taskService;

    @ActionMethod(cmd = Command.GetTasks)
    public void getTasks(GameFlowContext context){
        context.sendResponse(DataConstant.BROADCAST_MESSAGE,Command.GetTasks, taskService.getTaskList(context.getUserId())); //任务信息
    }

    @ActionMethod(cmd = Command.CompleteTasks)
    public void completeTasks(GameFlowContext<DefaultPacket> context){
        DefaultPacket defaultPacket = context.getPacket();
        Integer taskId = DataCodecKit.decode(defaultPacket.getPacket(),Integer.class);
        taskService.completeTask(context,taskId);
    }
}
